package com.test.springboot.springboot3testdemo3.controller;

import com.test.springboot.springboot3testdemo3.service.CornBasedThreadPoolMonitorScheduleTask;
import com.test.springboot.springboot3testdemo3.service.FixRateBasedThreadPoolMonitorScheduleTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/9/27-08:45
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@RestController
public class ModifyThreadPoolMonitorScheduleController {
  private static final Logger LOGGER =
      LoggerFactory.getLogger(ModifyThreadPoolMonitorScheduleController.class);
  private CornBasedThreadPoolMonitorScheduleTask scheduleTask;
  private FixRateBasedThreadPoolMonitorScheduleTask fixRateScheduleTask;

  /*@Autowired
  public void setScheduleTask(CornBasedThreadPoolMonitorScheduleTask scheduleTask) {
    this.scheduleTask = scheduleTask;
  }*/

  @Autowired
  public void setFixRateScheduleTask(
      FixRateBasedThreadPoolMonitorScheduleTask fixRateScheduleTask) {
    this.fixRateScheduleTask = fixRateScheduleTask;
  }

  @GetMapping("/updateCorn")
  public String updateCorners(String corn) {
    LOGGER.info("new corn is {}", corn);
    scheduleTask.setCorn(corn);
    return "modify success";
  }

  @GetMapping("/updateTimer")
  public String updateTimer(Long delay) {
    LOGGER.info("new timer is {}", delay);
    fixRateScheduleTask.setDelay(delay);
    return "modify success";
  }
}
